from db.dbUtils import MysqlPool


def insert_call_into_at_class(sql):
    with MysqlPool() as pool:
        c = pool.cursor
        try:
            c.execute(sql)
            pool.conn.commit()
            return True
        except Exception as e:
            print(e)
            pool.conn.rollback()
            return False


def exist_z_t_j(class_id, z, t, j):
    with MysqlPool() as pool:
        c = pool.cursor
        sql = """select * from se_at_class where week={} and day={} and th={} and class_id='{}'""".format(z, t, j, class_id)
        c.execute(sql)
        return c.fetchall()
